﻿using System;
using System.Collections.Generic;
using System.Text;
using Xeno.Core;
namespace Xeno.Filter
{
    public class FilterDOF : XenoFilter
    {
        public XenoTexture2D ZFrame;
        public XenoTextureDepth ZBuf;

        public FilterDOF(int res)
            : base(res)
        {
            NeedsFrame = true; 
            FrameMat = new XenoMaterial("DOFMat");
            FrameMat.Effect = new XenoEffect("Content/Shader/XenoMaterial_Depth.vertex", "Content/Shader/XenoMaterial_Depth.fragment");
            ZFrame = new XenoTexture2D((int)XenoCore.DisplayWidth, (int)XenoCore.DisplayHeight);
            ZBuf = new XenoTextureDepth((int)XenoCore.DisplayWidth, (int)XenoCore.DisplayHeight);
        }
        public override XenoTexture2D DoRender()
        {

            GraphToBuffer(ZFrame, ZBuf, ActualGraph, FrameMat);

            BlurBuffer(FrameBuffer, ZFrame, Output);


            //BufferToBuffer(ZFrame, Output, TransferMat);


            //Target.Bind();
           // Target.AttachTexture(Output);
            //Target.AttachDepth(OutputDepth);
            //     TmpMat.DiffuseMap = ZFrame;
            //DrawMat(0, 0, Global.DisplayWidth,Global.DisplayHeight, TmpMat);
            //Target.Unbind();


            return Output;
        }


    }
}
